#include "Charset.h"

#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Type.h"
#include "UnsupportedErr.h"


Type* Charset_classType = NULL;
VTable* Charset_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Bool equals(Obj? obj) */
Bool Charset_equals(Obj self, NullableObj obj)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Charset.equals not implemented yet"));
}


/* Int hash() */
Int Charset_hash(Obj self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Charset.hash not implemented yet"));
}


/* Str toStr() */
Str* Charset_toStr(Obj self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Charset.toStr not implemented yet"));
}


/* Charset? fromStr(Str name, Bool checked) */
Charset* Charset_fromStr_1(Str* name)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Charset.fromStr not implemented yet"));
}


/* Charset? fromStr(Str name, Bool checked) */
Charset* Charset_fromStr(Str* name, Bool checked)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Charset.fromStr not implemented yet"));
}


/* Charset defVal() */
Charset* Charset_defVal(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Charset.defVal not implemented yet"));
}


/* Charset utf8() */
Charset* Charset_utf8(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Charset.utf8 not implemented yet"));
}


/* Charset utf16BE() */
Charset* Charset_utf16BE(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Charset.utf16BE not implemented yet"));
}


/* Charset utf16LE() */
Charset* Charset_utf16LE(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Charset.utf16LE not implemented yet"));
}


/* Str name() */
Str* Charset_name(Charset* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Charset.name not implemented yet"));
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* Charset_initType(void)
{
  if (Charset_classType == NULL)
  {
    Type* baseType = Obj_initType();
    VTable* vtable = Charset_initVTable();
    Type* type = Type_new("Charset", baseType, vtable, sizeof(Charset), sizeof(CharsetVTable));
    Type_registerMethodImplementation(type, "defVal", Charset_defVal, 0);
    Type_registerMethodImplementation(type, "equals", Charset_equals, 1);
    Type_registerMethodImplementation(type, "fromStr", Charset_fromStr_1, 1);
    Type_registerMethodImplementation(type, "fromStr", Charset_fromStr, 2);
    Type_registerMethodImplementation(type, "hash", Charset_hash, 0);
    Type_registerMethodImplementation(type, "name", Charset_name, 0);
    Type_registerMethodImplementation(type, "toStr", Charset_toStr, 0);
    Type_registerMethodImplementation(type, "utf16BE", Charset_utf16BE, 0);
    Type_registerMethodImplementation(type, "utf16LE", Charset_utf16LE, 0);
    Type_registerMethodImplementation(type, "utf8", Charset_utf8, 0);
    Charset_classType = type;
    Charset_initStatic();
  }
  return Charset_classType;
}


VTable* Charset_initVTable(void)
{
  if (Charset_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(CharsetVTable));
    memcpy(vtable, Obj_initVTable(), sizeof(FanObjVTable));
    ((FanObjVTable*)vtable)->equals = Charset_equals;
    ((FanObjVTable*)vtable)->hash = Charset_hash;
    ((FanObjVTable*)vtable)->toStr = Charset_toStr;
    Charset_classVTable = vtable;
  }
  return Charset_classVTable;
}


void Charset_initStatic(void)
{
}
